﻿var modalApproveProject;

$().ready(function () {
    modalApproveProject = new ModalApproveProject();
    modalApproveProject.init();
});

function ModalApproveProject() {
    var _this = this;
    var ajaxUrl = "/Manager/ChangeState";
    this.init = function () {

        $(".status").click(function () {
            var item = $(this).siblings(".report-id");
            OpenConfirm("Are you sure you want to confirm the report?",
                    function () {
                        _this.execute(item.val());
                    });
        });
    }

    this.execute = function (ID) {

        var dataAjax = {
            id: ID,
            state: 1
        };

        $.ajax(
        {
            type: "POST",
            url: ajaxUrl,
            data: dataAjax,
            success: function (data) {
                if (data.result == "ok") {
                    window.location.replace(document.location.href);
                }
                else {
                }
            },
            error: function () {
                alert("Erro");
            }
        });
    }
}